//
//  MoreButton.swift
//  Automobile
//
//  Created by erkebulan elzhan on 8/15/20.
//  Copyright © 2020 erkebulan elzhan. All rights reserved.
//

import UIKit
import SnapKit

final class MoreButton: UIView {
    
    private lazy var titleLbl: UILabel = {
        let lbl = UILabel()
        lbl.font = UIFont.systemFont(ofSize: 15, weight: .medium)
        lbl.textColor = .rgb(47, 130, 210)
        lbl.textAlignment = .left
        lbl.sizeToFit()
        return lbl
    }()
    
    private lazy var arrowImg: UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage(named: "arrow")
        return imageView
    }()
    
    init () {
        super.init(frame: .zero)
        self.addViews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    public func setUp (text: String, isTitle: Bool = false) {
        self.titleLbl.text = text
        if (isTitle) {
            self.titleLbl.textColor = .darkBlueColor
            self.titleLbl.font = UIFont.systemFont(ofSize: 17, weight: .bold)
        }
    }
    
    
    private func addViews () {
        self.addSubview(titleLbl)
        self.addSubview(arrowImg)
        
        
        arrowImg.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.trailing.equalToSuperview().inset(16)
            make.width.equalTo(8)
            make.height.equalTo(13)
        }
        titleLbl.snp.makeConstraints { (make) in
            make.centerY.leading.equalToSuperview()
            make.trailing.equalTo(arrowImg.snp.leading).offset(-16)
        }
        
        self.snp.makeConstraints { (make) in
            make.height.equalTo(32)
        }
    }
}
